﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using HotelSoft.HotelManagement_BUS;
using HotelSoft.HotelManagement_DTO;
using HotelSoft.HotelManagement_DAO;
using System.Collections;

namespace HotelSoft.HotelManagement_GUI
{
    public partial class frBaoCaoDoanhThu : Form
    {

        BaoCaoDoanhThuBUS busDT = new BaoCaoDoanhThuBUS();
        ArrayList dsBC = new ArrayList();
        BindingSource bsData = null;
        Double temp = 1;
        int iBaoCaoTheo;
        DateTime tNgay;
        BaoCaoDoanhThuBUS busBaoCao = new BaoCaoDoanhThuBUS();
        DataTable kqBaoCao = new DataTable();
        public frBaoCaoDoanhThu()
        {
            InitializeComponent();
            TienIch thamso = new TienIch();
            cbHinhThuc.Items.Add(thamso.dsYeuCauBaoCao[0].ToString());//Ngày
            cbHinhThuc.Items.Add(thamso.dsYeuCauBaoCao[1].ToString());//Tháng
            cbHinhThuc.Items.Add(thamso.dsYeuCauBaoCao[2].ToString());//Năm
            cbHinhThuc.SelectedIndex = 0;
        }
        public frBaoCaoDoanhThu(int _BaoCaoTheo)
        {
            InitializeComponent();
            TienIch thamso = new TienIch();
            cbHinhThuc.Items.Add(thamso.dsYeuCauBaoCao[0].ToString());//Ngày
            cbHinhThuc.Items.Add(thamso.dsYeuCauBaoCao[1].ToString());//Tháng
            cbHinhThuc.Items.Add(thamso.dsYeuCauBaoCao[2].ToString());//Năm
            iBaoCaoTheo = _BaoCaoTheo;
            cbHinhThuc.SelectedIndex = _BaoCaoTheo;
        }

        private void buttonX4_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }

        private void buttonX2_Click(object sender, EventArgs e)
        {
            //MessageBox.Show("Xuất ra file exel");
            string filename = "BaoCaoDoanhThu.xls";
            TienIch.ExportToExcel(kqBaoCao, filename);
            TienIch.TryToDisplayGeneratedFile(filename);
        }

        private void buttonX3_Click(object sender, EventArgs e)
        {
            //MessageBox.Show("Xuất ra file HTML");
            string filename = "baocao.html";
            TienIch.ExportToHtml(kqBaoCao, filename);
            TienIch.TryToDisplayGeneratedFile(filename);
        }

        private void XuatDanhSach(ArrayList dsBC)
        {
            gvds.AutoGenerateColumns = false;
            this.bsData = new BindingSource(dsBC, "");
            gvds.DataSource = bsData;
        }

        private void buttonX1_Click(object sender, EventArgs e)
        {
            try
            {
                iBaoCaoTheo = cbHinhThuc.SelectedIndex;
                tNgay = Convert.ToDateTime(dtChon.Text);
                switch (iBaoCaoTheo)
                {
                    case 0:
                        kqBaoCao = busDT.BaoCaoDoanhThuNgay(tNgay);
                        break;
                    case 1:
                        kqBaoCao = busDT.BaoCaoDoanhThuThang(tNgay);
                        break;
                    case 2:
                        kqBaoCao = busDT.BaoCaoDoanhThuNam(tNgay);
                        break;
                }
               gvds.DataSource = kqBaoCao.DefaultView; 
            }
            catch { }
        }

        private void gvds_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {

        }

        private void frBaoCaoDoanhThu_Load(object sender, EventArgs e)
        {
            timer1.Enabled = true;
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            this.Opacity = this.Opacity + 0.1;
            if (this.Opacity == temp)
            {
                timer1.Enabled = false;
            }
        }
    }
}
